﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace SomeKit.TypeSafe
{
	public static partial class ClientHelper
	{
        private static Action<string> EnsureEmptyResultHandler(Action<Exception> errorHandler, Action handler = null)
        {
            return res =>
            {
                Debug.Assert(string.IsNullOrEmpty(res));
                if (!string.IsNullOrEmpty(res) && errorHandler != null)
                    errorHandler(new Exception(string.Format("Invalid result from service. Empty result expected. \"{0}\" received.", res)));
                if (handler != null)
                    handler();
            };
        }
	}
}
